# -*- coding: utf-8 -*-
"""
Created on Fri Jan 11 00:52:48 2013

@author: Winand
"""

from webapi.server.remotedict import RemoteDict
from webapi.log import error
print "CONFIG ZEROED"
configs={}

def cget(name, d=None):
    opt = name.strip("/").split("/", 1)
    if len(opt)==2:
        if opt[0] not in configs:
            configs[opt[0]] = RemoteDict(opt[0], perm=True)
        print 'get dump', configs[opt[0]]
        return configs[opt[0]].get(opt[1], d)
    else: 
        error("config get: Wrong config path")
        return d

def cset(name, v):
    opt = name.strip("/").split("/", 1)
    if len(opt)==2:
        if opt[0] not in configs:
            configs[opt[0]] = RemoteDict(opt[0], perm=True)
        configs[opt[0]][opt[1]] = v
        print 'set dump', configs[opt[0]]
    else: error("config set: Wrong config path")
        